<?php
/**
 * A simple example login page for PageBricks_Auth.
 * 
 * @version Auth_r12+
 * @package    PageBricks
 * @subpackage Xamples
 * @filesource
 * 
 */
/**
 *
 */
$user=$auth->getUsername();
$status = $auth->getStatus();
//adapt status reports according to app
$statusReports = array(
					-1=>'Exception',
					0=>'Undetermined state',
					1=>'OK',
					101=>'User not logged in yet',
					102=>'Exceeded the maximum of allowed login attempts.',
					103=>'Session expired',
					104=>'User idled',
					111=>'IP changed',
					112=>'User agent changed',
					113=>'Bad request',
					201=>'Login succeeded',
					202=>'Login credentials wrong',
					203=>'Login credentials incomplete',
					301=>'Logout succeeded',
					302=>'Logout failed',
					311=>'Logout requested',
					312=>'Logout called by script'
					  );
if ($status > 1) {
	$status = 'Status: ' . $statusReports[$status];
} else {
	$status = '';
}

$captchaimg = '';
//$user = '';
//$status = '';
/**	
require_once('recaptchalib.php');
	// Get a key from http://recaptcha.net/api/getkey
	$publickey = "";
	$privatekey = "";
	
	# the response from reCAPTCHA
	$resp = null;
	# the error code from reCAPTCHA, if any
	$error = null;
		
	# was there a reCAPTCHA response?
	if (isset($_POST['recaptcha_response_field'])) {
	        $resp = recaptcha_check_answer ($privatekey,
	                                        $_SERVER['REMOTE_ADDR'],
	                                        $_POST['recaptcha_challenge_field'],
	                                        $_POST['recaptcha_response_field']);
	
	        if ($resp->is_valid) {
	                echo "You got it!";
	                header(sprintf('Location: http://localhost:8080/%s',$auth->getScriptName()));
	        } else {
	                # set the error code so that we can display it
	                $error = $resp->error;
	        }
	}
	$captchaimg = recaptcha_get_html($publickey, $error);
*/
echo <<<EOT
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="Language" content="german, de, deutsch" />
	<meta http-equiv="Content-Language" content="de" />
	<script type= "text/javascript">
			var RecaptchaOptions = {
				theme : 'blackglass'
			}		
	</script>
	<title>Login</title>
	</head>
	<style>
		label {
			display: block;
			float: left;
			width: 8em;
		}
	</style>
	
<body>
<div style="width: 35%; padding: 1em; background-color: lightgray">
	<form action="" method="post">
	<div style="color: red; width: 80%">$status</div>
		<fieldset style="padding: 1em">
			<label for="username">Benutzername</label>
			<input type="text" name="username" id="username" value="$user" />
			<br />
			<br />
			<label for="password">Passwort</label>
			<input type="password" name="password" id="pwd"/>
			<br />
			<br />
			<input type="submit" name="submit" value="einloggen" />
			$captchaimg
		</fieldset>
	</form>
</div>
</body>
</html>
EOT;
